﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CygwinPackageManager
{
	public static class Utils
	{
		public static string Serialize(IEnumerable<int> integers)
		{
			if (integers == null)
				throw new ArgumentException();

			string s = string.Empty;

			foreach (int integer in integers)
				s += string.Concat(integer, ";");

			return s;
		}

		public static IEnumerable<int> DeSerialize(string s)
		{
			if (string.IsNullOrEmpty(s))
				throw new ArgumentException();

			List<int> integers = new List<int>();

			foreach (string part in s.Split(';'))
				if (!string.IsNullOrEmpty(part))
					integers.Add(Int32.Parse(part));
			
			return integers;
		}
	}
}
